﻿using Company.Shell.Models;

namespace Company.Shell.Extensions
{
    public static class RoomParameterExtension
    {
        /// <summary>
        /// 获取房间温度参数集合
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static ushort[] GetTemperatureParameters(this RoomParameter parameter)
        {
            List<ushort> result = new()
            {
                (ushort)(parameter.TemperatureP * 10),
                (ushort)(parameter.TemperatureI * 10),
                (ushort)(parameter.TemperatureD * 10),
                (ushort)(parameter.TemperatureCycleTime * 10),
                (ushort)(parameter.TemperatureUpperLimit * 10),
                (ushort)(parameter.TemperatureLowerLimit * 10),
                (ushort)(parameter.TemperatureOpenTime * 10),
                (ushort)(parameter.TemperatureCloseTime * 10),
                (ushort)(parameter.TemperatureUpperTolerance * 10),
                (ushort)(parameter.TemperatureLowerTolerance * 10)
            };
            return result.ToArray();
        }

        /// <summary>
        /// 获取房间湿度参数集合
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static ushort[] GetHumidityParameters(this RoomParameter parameter)
        {
            List<ushort> result = new()
            {
                (ushort)(parameter.HumidityP * 10),
                (ushort)(parameter.HumidityI * 10),
                (ushort)(parameter.HumidityD * 10),
                (ushort)(parameter.HumidityCycleTime * 10),
                (ushort)(parameter.HumidityUpperLimit * 10),
                (ushort)(parameter.HumidityLowerLimit * 10),
                (ushort)(parameter.HumidityOpenTime * 10),
                (ushort)(parameter.HumidityCloseTime * 10),
                (ushort)(parameter.HumidityUpperTolerance * 10),
                (ushort)(parameter.HumidityLowerTolerance * 10)
            };
            return result.ToArray();
        }
    }
}
